package com.feimaopian.controller;

import com.feimaopian.entity.Article;
import com.feimaopian.entity.Comment;
import com.feimaopian.mapper.CommentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentMapper commentMapper;

    @PostMapping("/add")
    public boolean addComment(@RequestBody Comment comment) {
        if (comment == null) {
            return false;
        }
        System.out.println("add"+commentMapper.findAll());
        return commentMapper.addComment(comment) == 1;
    }

    @GetMapping("/findAll")
    public List<Comment> findAll() {
        System.out.println("find"+commentMapper.findAll());
        return commentMapper.findAll();
    }


}
